﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：QS_CB_SBDYGXB实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class QS_CB_SBDYGXB
    {

        private decimal m_dec_id;
        /// <summary>
        /// 主键
        /// </summary>
        public decimal ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private string m_str_s_yhh;
        /// <summary>
        /// 用户号
        /// </summary>
        public string S_YHH { get { return m_str_s_yhh; } set { m_str_s_yhh = value; } }

        private string m_str_s_yhm;
        /// <summary>
        /// 用户名
        /// </summary>
        public string S_YHM { get { return m_str_s_yhm; } set { m_str_s_yhm = value; } }

        private string m_str_s_sbh_zls;
        /// <summary>
        /// 水表号-自来水
        /// </summary>
        public string S_SBH_ZLS { get { return m_str_s_sbh_zls; } set { m_str_s_sbh_zls = value; } }

        private string m_str_s_sbh_szy;
        /// <summary>
        /// 水表号-水资源
        /// </summary>
        public string S_SBH_SZY { get { return m_str_s_sbh_szy; } set { m_str_s_sbh_szy = value; } }

        private decimal? m_dec_i_by1;
        /// <summary>
        /// 
        /// </summary>
        public decimal? I_BY1 { get { return m_dec_i_by1; } set { m_dec_i_by1 = value; } }

        private decimal? m_dec_i_by2;
        /// <summary>
        /// 
        /// </summary>
        public decimal? I_BY2 { get { return m_dec_i_by2; } set { m_dec_i_by2 = value; } }

        private decimal? m_dec_i_by3;
        /// <summary>
        /// 
        /// </summary>
        public decimal? I_BY3 { get { return m_dec_i_by3; } set { m_dec_i_by3 = value; } }

        private string m_str_s_by1;
        /// <summary>
        /// 
        /// </summary>
        public string S_BY1 { get { return m_str_s_by1; } set { m_str_s_by1 = value; } }

        private string m_str_s_by2;
        /// <summary>
        /// 
        /// </summary>
        public string S_BY2 { get { return m_str_s_by2; } set { m_str_s_by2 = value; } }

        private string m_str_s_by3;
        /// <summary>
        /// 
        /// </summary>
        public string S_BY3 { get { return m_str_s_by3; } set { m_str_s_by3 = value; } }

        private DateTime? m_DT_d_caozuorq;
        /// <summary>
        /// 
        /// </summary>
        public DateTime? D_CAOZUORQ { get { return m_DT_d_caozuorq; } set { m_DT_d_caozuorq = value; } }

        private string m_str_s_caozuor;
        /// <summary>
        /// 
        /// </summary>
        public string S_CAOZUOR { get { return m_str_s_caozuor; } set { m_str_s_caozuor = value; } }

        private decimal? m_dec_i_jlzt;
        /// <summary>
        /// 
        /// </summary>
        public decimal? I_JLZT { get { return m_dec_i_jlzt; } set { m_dec_i_jlzt = value; } }
        public QS_CB_SBDYGXB()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace BLL.Access
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class QS_CB_SBDYGXBProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public QS_CB_SBDYGXBProcess() { conn = Platform.Configuration.ConfigHelper.PlatformConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据QS_CB_SBDYGXB实体添加或者修改QS_CB_SBDYGXB信息
        /// </summary>
        public bool InsertOrUpdate(QS_CB_SBDYGXB QS_CB_SBDYGXB, OracleTransaction Transaction)
        {
            if (QS_CB_SBDYGXB.ID == 0)
            {
                InsertQS_CB_SBDYGXB(QS_CB_SBDYGXB, Transaction);
            }
            else
            {
                UpdateQS_CB_SBDYGXB(QS_CB_SBDYGXB, Transaction);
            }
            return QS_CB_SBDYGXB.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据QS_CB_SBDYGXB实体添加或修改QS_CB_SBDYGXB信息
        /// </summary>
        public bool InsertOrUpdate(QS_CB_SBDYGXB QS_CB_SBDYGXB)
        {
            return InsertOrUpdate(QS_CB_SBDYGXB, null);
        }



        /// <summary>
        /// 根据QS_CB_SBDYGXB主键删除QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_CB_SBDYGXB(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelQS_CB_SBDYGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据QS_CB_SBDYGXB主键删除QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_CB_SBDYGXB(decimal ID)
        {
            return DeleteQS_CB_SBDYGXB(ID, null);
        }

        /// <summary>
        /// 根据条件删除QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_CB_SBDYGXBsDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelQS_CB_SBDYGXBsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_CB_SBDYGXBsDynamic(string WhereClause)
        {
            return DeleteQS_CB_SBDYGXBsDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据QS_CB_SBDYGXB主键选择QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_CB_SBDYGXB信息</returns>
        public QS_CB_SBDYGXB SelectQS_CB_SBDYGXB(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_CB_SBDYGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                QS_CB_SBDYGXB QS_CB_SBDYGXB = PopulateQS_CB_SBDYGXB(rd);
                rd.Close();
                return QS_CB_SBDYGXB;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据QS_CB_SBDYGXB主键选择QS_CB_SBDYGXB信息
        /// </summary>
        /// <returns>QS_CB_SBDYGXB信息</returns>
        public QS_CB_SBDYGXB SelectQS_CB_SBDYGXB(decimal ID)
        {
            return SelectQS_CB_SBDYGXB(ID, null);
        }

        /// <summary>
        /// 选择所有QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有QS_CB_SBDYGXB信息</returns>
        public DataTable SelectQS_CB_SBDYGXBsAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_CB_SBDYGXBsAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有QS_CB_SBDYGXB信息
        /// </summary>
        /// <returns>所有QS_CB_SBDYGXB信息</returns>
        public DataTable SelectQS_CB_SBDYGXBsAll()
        {
            return SelectQS_CB_SBDYGXBsAll(null);
        }

        /// <summary>
        /// 根据条件选择QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_CB_SBDYGXB信息</returns>
        public DataTable SelectQS_CB_SBDYGXBsDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_CB_SBDYGXBsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>QS_CB_SBDYGXB信息</returns>
        public DataTable SelectQS_CB_SBDYGXBsDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectQS_CB_SBDYGXBsDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_CB_SBDYGXB信息</returns>
        public DataTable SelectQS_CB_SBDYGXBsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_CB_SBDYGXBsDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择QS_CB_SBDYGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>QS_CB_SBDYGXB信息</returns>
        public DataTable SelectQS_CB_SBDYGXBsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectQS_CB_SBDYGXBsDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新QS_CB_SBDYGXB字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_CB_SBDYGXBsDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdQS_CB_SBDYGXBDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新QS_CB_SBDYGXB字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_CB_SBDYGXBsDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateQS_CB_SBDYGXBsDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertQS_CB_SBDYGXB(QS_CB_SBDYGXB QS_CB_SBDYGXB, OracleTransaction Transaction)
        {
            string spName = "CS_InsQS_CB_SBDYGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_CB_SBDYGXB.S_YHH;
            storedParams[1].Value = QS_CB_SBDYGXB.S_YHM;
            storedParams[2].Value = QS_CB_SBDYGXB.S_SBH_ZLS;
            storedParams[3].Value = QS_CB_SBDYGXB.S_SBH_SZY;
            storedParams[4].Value = QS_CB_SBDYGXB.I_BY1;
            storedParams[5].Value = QS_CB_SBDYGXB.I_BY2;
            storedParams[6].Value = QS_CB_SBDYGXB.I_BY3;
            storedParams[7].Value = QS_CB_SBDYGXB.S_BY1;
            storedParams[8].Value = QS_CB_SBDYGXB.S_BY2;
            storedParams[9].Value = QS_CB_SBDYGXB.S_BY3;
            storedParams[10].Value = QS_CB_SBDYGXB.D_CAOZUORQ;
            storedParams[11].Value = QS_CB_SBDYGXB.S_CAOZUOR;
            storedParams[12].Value = QS_CB_SBDYGXB.I_JLZT;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            QS_CB_SBDYGXB.ID = Convert.ToInt32(storedParams[13].Value);
            return result;
        }
        private bool UpdateQS_CB_SBDYGXB(QS_CB_SBDYGXB QS_CB_SBDYGXB, OracleTransaction Transaction)
        {
            string spName = "CS_UpdQS_CB_SBDYGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_CB_SBDYGXB.S_YHH;
            storedParams[1].Value = QS_CB_SBDYGXB.S_YHM;
            storedParams[2].Value = QS_CB_SBDYGXB.S_SBH_ZLS;
            storedParams[3].Value = QS_CB_SBDYGXB.S_SBH_SZY;
            storedParams[4].Value = QS_CB_SBDYGXB.I_BY1;
            storedParams[5].Value = QS_CB_SBDYGXB.I_BY2;
            storedParams[6].Value = QS_CB_SBDYGXB.I_BY3;
            storedParams[7].Value = QS_CB_SBDYGXB.S_BY1;
            storedParams[8].Value = QS_CB_SBDYGXB.S_BY2;
            storedParams[9].Value = QS_CB_SBDYGXB.S_BY3;
            storedParams[10].Value = QS_CB_SBDYGXB.D_CAOZUORQ;
            storedParams[11].Value = QS_CB_SBDYGXB.S_CAOZUOR;
            storedParams[12].Value = QS_CB_SBDYGXB.I_JLZT;
            storedParams[13].Value = QS_CB_SBDYGXB.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private QS_CB_SBDYGXB PopulateQS_CB_SBDYGXB(IDataReader dr)
        {
            QS_CB_SBDYGXB QS_CB_SBDYGXB = new QS_CB_SBDYGXB();
            QS_CB_SBDYGXB.ID = dr["ID"] == DBNull.Value ? (decimal)0 : (decimal)dr["ID"];
            QS_CB_SBDYGXB.S_YHH = dr["S_YHH"] == DBNull.Value ? null : (string)dr["S_YHH"];
            QS_CB_SBDYGXB.S_YHM = dr["S_YHM"] == DBNull.Value ? null : (string)dr["S_YHM"];
            QS_CB_SBDYGXB.S_SBH_ZLS = dr["S_SBH_ZLS"] == DBNull.Value ? null : (string)dr["S_SBH_ZLS"];
            QS_CB_SBDYGXB.S_SBH_SZY = dr["S_SBH_SZY"] == DBNull.Value ? null : (string)dr["S_SBH_SZY"];
            QS_CB_SBDYGXB.I_BY1 = dr["I_BY1"] == DBNull.Value ? null : (decimal?)dr["I_BY1"];
            QS_CB_SBDYGXB.I_BY2 = dr["I_BY2"] == DBNull.Value ? null : (decimal?)dr["I_BY2"];
            QS_CB_SBDYGXB.I_BY3 = dr["I_BY3"] == DBNull.Value ? null : (decimal?)dr["I_BY3"];
            QS_CB_SBDYGXB.S_BY1 = dr["S_BY1"] == DBNull.Value ? null : (string)dr["S_BY1"];
            QS_CB_SBDYGXB.S_BY2 = dr["S_BY2"] == DBNull.Value ? null : (string)dr["S_BY2"];
            QS_CB_SBDYGXB.S_BY3 = dr["S_BY3"] == DBNull.Value ? null : (string)dr["S_BY3"];
            QS_CB_SBDYGXB.D_CAOZUORQ = dr["D_CAOZUORQ"] == DBNull.Value ? null : (DateTime?)dr["D_CAOZUORQ"];
            QS_CB_SBDYGXB.S_CAOZUOR = dr["S_CAOZUOR"] == DBNull.Value ? null : (string)dr["S_CAOZUOR"];
            QS_CB_SBDYGXB.I_JLZT = dr["I_JLZT"] == DBNull.Value ? null : (decimal?)dr["I_JLZT"];
            return QS_CB_SBDYGXB;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion